﻿
<template>
    <div id="dvContent">
        <div class="btn-add">
            <button type="button" class="btn btn-info btn-lg" @click="addLC()"><i class="iconfont icon-jiahao ft12 mr5"></i>添加表单模板</button>
        </div>
        <div class="tab-filter-type">
            <!-- 搜索 -->
            <div class="oh mt20">
                <h5 class="pull-left tr">表单类别：</h5>
                <ul class="tab-type ft14" style="height: 40px;">
                    <li v-for="(el,index) in TypeData" @click="SelectType(el.ProcessClass)"><span v-bind:class="{active:index==0}" v-text="el.ProcessClass"></span></li>
                </ul>
            </div>
            <div class="oh" style="display: none">
                <div class="input-group ml15" style="width: 295px;">
                    <input type="search" class="form-control" v-model="searchcontent" placeholder="搜索表单名称">
                    <span class="input-group-addon" @click="GetLIST()">搜索</span>
                </div>
            </div>
        </div>
        <div class="default-tab ft14 padding20">
            <base-table :pzoption="tableop">
            </base-table>
        </div>


    </div>
</template>

<script>
    module.exports = {
        props: ['pdata'],
        components: {
            'base-table': httpVueLoader('/ViewV5/Base/Vue/Table.vue')
        },
        data: function () {
            return {
                TypeData: [],
                curLeiBie: "",
                searchcontent:"",
                tableop: {
                    title: "数据集",
                    issel: false,
                    iscz: true,
                    dataset: [],
                    czltabledata: [
                        {
                            colname: "设置表单", bttype: "text", isshow: true,  mangefun: function (rowdata) {
                                top.ComFunJS.winviewform("/ViewV5/AppPage/APP_ADD.html?FormCode=FORMBI_PROCESS&ID=" + rowdata.ID, "表单设置", "1000");
                            },
                        },
                        {
                            colname: "设计", bttype: "text", isshow: true,  mangefun: function (rowdata) {
                                window.open("/ViewV5/AppPage/FORMBI/FormBuildV1.html?ID=" + rowdata.ID, "_blank");
                            },
                        },
                        {
                            colname: "预览", bttype: "text", isshow: true,  mangefun: function (rowdata) {
                                window.open("/ViewV5/AppPage/FORMBI/FormAdd.html?pdid=" + rowdata.ID, "_blank");
                            },
                        },
                        {
                            colname: "删除", bttype: "text", isshow: true,  mangefun: function (rowdata) {
                                this.$parent.DelProcess(rowdata);
                            }
                        }
                    ],
                    collist: [
                        { colid: "ProcessName", colname: "表单名称", isshow: true, istip: true },
                        { colid: "ProcessClass", colname: "表单类别", isshow: true, istip: true },
                        { colid: "CRUser", colname: "创建人", isshow: false, istip: true },
                        { colid: "CRDate", colname: "创建时间", isshow: false, istip: true },

                    ]
                }
            }
        },
        methods: {
            InitWigetData: function () {
                var pro = this;
                $.getJSON('/api/Bll/ExeAction?Action=FORMBI_GETLCBDLB', {}, function (resultData) {
                    pro.TypeData = resultData.Result;
                    pro.curLeiBie = pro.TypeData[0].ProcessClass;
                    pro.GetLIST();
                })
            },
            SelectType: function (type) {
                this.curLeiBie = type;
                this.GetLIST();
            },
            DelProcess: function (item) {
                var pro = this;
                top.ComFunJS.winconfirm("<span style='color:red'>确定要删除吗？</span>", function () {
                    $.getJSON("/api/Bll/ExeAction?Action=FORMBI_DELPROCESSBYID", { P1: item.ID }, function (result) {
                        top.ComFunJS.winsuccess("删除成功");
                        pro.GetLIST();
                    })
                }, function () { })
            },
            addLC: function () {
                top.ComFunJS.winviewform("/ViewV5/AppPage/APP_ADD.html?FormCode=FORMBI_PROCESS", "添加");
            },
            SetColumnStatus: function (dom, item) {
                top.ComFunJS.winconfirm("确定要" + $.trim($(dom).html()) + "“" + item.ProcessName + "”吗？", function () {
                    $.getJSON("/api/Bll/ExeAction?Action=FORMBI_MODIFYLCSTATE", { P1: $.trim($(dom).html()) == "禁用" ? "N" : "Y", P2: item.ID }, function (result) {
                        top.ComFunJS.winsuccess($(dom).text() + "“" + item.ProcessName + "”成功");
                        $(dom).html($.trim($(dom).html()) == "禁用" ? "启用" : "禁用");
                    })
                })

            },
            GetLIST: function () {
                var pro = this;
                $.getJSON('/api/Bll/ExeAction?Action=FORMBI_GETWFPDLIST', { Content: pro.searchcontent, LB: pro.curLeiBie }, function (result) {
                    pro.tableop.dataset = result.Result;
                })
            }
        },
        mounted: function () {
            var pro = this;
            pro.$nextTick(function () {
                pro.InitWigetData();
            })

        },
        watch: {
            childpro: { //深度监听，可监听到对象、数组的变化
                handler(newV, oldV) {
                },
                deep: true
            }
        }
    };
</script>